package com.vf.admin.miaodong.controller;


import com.vf.admin.common.BaseController;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppComment;
import com.vf.admin.miaodong.service.AfterCommentService;
import com.vf.admin.utils.StringEx;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/after/comment")
public class AfterCommentController extends BaseController {

    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    AfterCommentService afterCommentService;

    @RequestMapping("/list")
    public String list(SplitPageBean splitPageBean, String startDate, String endDate, String nick, String phone) {
        try {
            Map<String,Object> objectMap = new HashMap<>();

            if (StringEx.isNotNull(startDate)){
                objectMap.put("startDate",startDate);
            }
            if (StringEx.isNotNull(endDate)){
                objectMap.put("endDate",endDate);
            }
            if (StringEx.isNotNull(startDate)){
                objectMap.put("status",1);
            }
            if (StringEx.isNotNull(nick)){
                objectMap.put("nick",nick);
            }
            if (StringEx.isNotNull(phone)){
                objectMap.put("phone",phone);
            }
            objectMap.put("status",1);
            List<AppComment> appCommentList =  afterCommentService.list(objectMap,splitPageBean);
            request.setAttribute("list",appCommentList);
            request.setAttribute("splitPage",splitPageBean);
            request.setAttribute("phone",phone);
            request.setAttribute("nick",nick);
            request.setAttribute("startDate",startDate);
            request.setAttribute("endDate",endDate);
            return this.sucess("/web/after/comment/list");
        } catch (Exception e) {
            e.printStackTrace();
            logger.error("动态列表异常", e);
            return this.error("系统繁忙");
        }


    }


}
